package cn.larry.aop.config.advice;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

/**
 * @author LarryZeal
 *
 */
@Profile("args")
@Aspect
@Component
public class ArgsAdvice {
	private static Logger logger = LoggerFactory.getLogger(ArgsAdvice.class);

	@Before("cn.larry.aop.config.aspect.ArgsAspect.demoArgs1()")
	public void before(JoinPoint jp) {
		logger.info(jp.toLongString());
	}

	// 拦截参数，并注入这里！
	@Before("cn.larry.aop.config.aspect.ArgsAspect.demoArgs11(name)")
	public void before(JoinPoint jp, String name) {
		logger.info(jp.toLongString() + "----" + name);
	}

	@Before("cn.larry.aop.config.aspect.ArgsAspect.demoArgs2()")
	public void before2(JoinPoint jp) {
		logger.info(jp.toLongString());
	}

	@Before("cn.larry.aop.config.aspect.ArgsAspect.demoArgs3()")
	public void before3(JoinPoint jp) {
		logger.info(jp.toLongString());
	}
}
